<template>
	<view class="testRecord">
		<view class="tr_item">
			<view class="item" v-for="(item, index) in orderList">
				<view class="main">
					<view class="title">{{ item.title }}</view>
					<view class="see" @click="seeScores(item, index)">查看分数</view>
				</view>
				<view class="wraf">提交时间：{{ item.create_time }}</view>
			</view>
			<!-- <view class="item">
				<view class="main">
					<view class="title">英语付费模拟考试</view>
					<view class="see" @click="seeScores()">查看分数</view>
				</view>
				<view class="wraf">提交时间：2021-2-1-25 10:00</view>
			</view>
			<view class="item">
				<view class="main">
					<view class="title">英语付费模拟考试</view>
					<view class="see" @click="seeScores()">查看分数</view>
				</view>
				<view class="wraf">提交时间：2021-2-1-25 10:00</view>
			</view> -->
			<noData text="暂时没有数据" v-if="orderList.length == 0"></noData>
			<u-loadmore :status="status" icon-color="#267dff" v-if="last_page > 1" />
		</view>
	</view>
</template>

<script>
import noData from '@/components/xs-components/noData.vue';
export default {
	components: {
		noData
	},
	data() {
		return {
			orderList: [],
			page: 1,
			last_page: 0,
			status: 'loadmore' // loadmore loading nomore
		};
	},
	onLoad() {
		// console.log(this.letterList)
		this.postData();
	},
	created() {
		// console.log(this.letterList.length)
	},
	methods: {
		// 查看分数
		seeScores(item, index) {
			uni.navigateTo({ url: './testScores?exam_id='+item.id });
		},
		// 获取数据
		postData() {
			this.$api
				.post(global.apiUrls.testRecord, {
					page: this.page
				})
				.then(res => {
					console.log(res);
					uni.hideLoading();
					this.last_page = res.data.data.last_page;
					this.orderList = res.data.data.data;
					this.$forceUpdate();
				})
				.catch(err => {
					// this.$popup.showToast('保存失败')
				});
		}
	},
	onReachBottom() {
		if (this.page >= this.last_page) return (this.status = 'nomore');
		this.page++;
		this.status = 'loading'; // loadmore loading nomore
		this.postData();
	}
};
</script>

<style lang="scss" scoped>
.testRecord {
	.tr_item {
		padding: 0 32upx;
		.item {
			padding: 40upx 0;
			border-bottom: 1px solid #eeeeee;
			.main {
				display: flex;
				align-items: center;
				justify-content: space-between;
				.title {
					font-size: 32upx;
					font-weight: bold;
					color: #333333;
				}
				.see {
					font-size: 28upx;
					color: #267dff;
				}
			}
			.wraf {
				margin-top: 32upx;
				font-size: 24upx;
				color: #999999;
			}
		}
	}
}
</style>
